#include <rtthread.h>
#include "bsp_include.h"
#include "TCA9539.h"
long ledctrl(int argc, char**argv)
{
    static uint8_t status;
    if(argc < 2)
    {
        return -1;
    }
    if(!rt_strcmp(argv[1],"0"))
    {
       if(!rt_strcmp(argv[2],"1"))
       {
           status |= 0x80;
       }
       else
       {
           status &= ~0x80;
       }
    }
    if(!rt_strcmp(argv[1],"1"))
    {
       if(!rt_strcmp(argv[2],"1"))
       {
           status |= 0x40;
       }
       else
       {
           status &= ~0x40;
       }
    }
    if(!rt_strcmp(argv[1],"2"))
    {
       if(!rt_strcmp(argv[2],"1"))
       {
           status |= 0x20;
       }
       else
       {
           status &= ~0x20;
       }
    }
    if(!rt_strcmp(argv[1],"on"))
    {
       status |= 0xE0;
    }
    if(!rt_strcmp(argv[1],"off"))
    {
       status &= ~0xE0;
    }
    ledcontrol(status);
    return 0;
}

FINSH_FUNCTION_EXPORT(ledctrl, LED Control ledctrl: <num|value>);
MSH_CMD_EXPORT(ledctrl, LED Control ledctrl: <num|value>);



